package com.renwei.yunlong.activity;

import android.os.Bundle;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.StaggeredGridLayoutManager;
import android.view.View;
import android.view.Window;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

import com.renwei.yunlong.R;
import com.renwei.yunlong.adapter.ExpertiseInternetAdapter;
import com.renwei.yunlong.base.BaseActivity;
import com.renwei.yunlong.view.SpaceItemDecoration;
import com.zyf.fwms.commonlibrary.utils.AutoUtils;
import com.zyf.fwms.commonlibrary.utils.CommonUtils;
import com.zyf.fwms.commonlibrary.utils.StatusBarUtil;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * 技术专长（限五个）
 * <p>
 * Created by Administrator on 2017/8/25.
 */

public class ExpertiseActivity extends BaseActivity implements View.OnClickListener {

    @Bind(R.id.iv_back)
    ImageView ivBack;
    @Bind(R.id.tv_title)
    TextView tvTitle;
    @Bind(R.id.tv_edit)
    TextView tvEdit;
    @Bind(R.id.recycler_safety)
    RecyclerView recyclerSafety;
    @Bind(R.id.recycler_internet)
    RecyclerView recyclerInternet;

    private ExpertiseInternetAdapter internetAdapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.activity_expertise);
        ButterKnife.bind(this);

        StatusBarUtil.setColor(this, CommonUtils.getColor(this, R.color.title_color), 0);
        //屏幕自适配
        AutoUtils.setSize(this, false, 720, 1280);
        AutoUtils.auto(this);

        initData();
    }

    private void initData() {
        ivBack.setVisibility(View.VISIBLE);
        tvEdit.setVisibility(View.VISIBLE);
        tvTitle.setText("技术专长（限五个）");
        tvEdit.setText("提交");
        ivBack.setOnClickListener(this);

        recyclerInternet.setLayoutManager(new StaggeredGridLayoutManager(3, StaggeredGridLayoutManager.VERTICAL));
        int spacingInPixels = getResources().getDimensionPixelSize(R.dimen.space_pixels);
        recyclerInternet.addItemDecoration(new SpaceItemDecoration(spacingInPixels));
        internetAdapter = new ExpertiseInternetAdapter(this, new ExpertiseInternetAdapter.ExpertiseInternetOnClickListener() {
            @Override
            public void setOnClickListener(String content) {
                Toast.makeText(ExpertiseActivity.this, content, Toast.LENGTH_SHORT).show();
            }
        });

        internetAdapter.setOnItemClickListener(new ExpertiseInternetAdapter.OnItemClickListener() {
            @Override
            public void onItemClick(View view, int position, String s) {
                internetAdapter.setSelection(position);//传递当前的点击位置
                internetAdapter.notifyDataSetChanged();//通知刷新
            }
        });
        recyclerInternet.setAdapter(internetAdapter);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.iv_back:
                finish();
                break;
            case R.id.tv_edit:
                break;
            default:
                break;
        }
    }
}
